unixFriendly <- function(x){
  x <- colnames(x)
  x <- tolower(x)
  x <- gsub(" ", "_", x)
  x
}

smoothPosterior <- function(posterior){
  posterior2 <- posterior %>%
    filter(quantile != "mu") %>%
    select(case, high_mutation_rate, quantile, value, mut.per.yr) %>%
    spread(quantile, value) %>%
    arrange(median)
  fit.med <- loess(median~mut.per.yr, data=posterior2, span=1/3)
  fit.lwr <- loess(lower~mut.per.yr, data=posterior2, span=1/3)
  fit.upr <- loess(upper~mut.per.yr, data=posterior2, span=1/3)
  mns <- predict(fit.med, data=data.frame(mut.per.yr=posterior2$mut.per.yr))
  lwr <- predict(fit.lwr, data=data.frame(mut.per.yr=posterior2$mut.per.yr))
  upr <- predict(fit.upr, data=data.frame(mut.per.yr=posterior2$mut.per.yr))
  posterior3 <- tibble(case=posterior2$case,
                     mut.per.yr=posterior2$mut.per.yr,
                     median=mns,
                     lower=lwr,
                     upper=upr)
  posterior3
}
